---
image: /generated/articles-docs-gif-get-gif-duration-in-seconds.png
title: getGifDurationInSeconds()
id: get-gif-duration-in-seconds
crumb: '@remotion/gif'
---

_Part of the [`@remotion/gif`](/docs/gif) package_

_Available from v3.2.22_

Gets the duration in seconds of a GIF.

:::note
Remote GIFs need to support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).

<details>
  <summary>More info</summary>
  <ul>
    <li>
      Remotion's origin is usually <code>http://localhost:3000</code>, but it may be different if rendering on Lambda or the port is busy.
    </li>
    <li>
      You can <a href="/docs/chromium-flags#--disable-web-security">disable CORS</a> during renders.
    </li>
  </ul>
</details>
:::

## Arguments

### `src`

A string pointing to a GIF asset

## Return value

`Promise<number>` - the duration of the GIF in seconds, not factoring in that whether it is looped.

## Example

```tsx twoslash
import {useCallback, useEffect} from 'react';
import {staticFile} from 'remotion';
// ---cut---
import {getGifDurationInSeconds} from '@remotion/gif';
import gif from './cat.gif';

const MyComp: React.FC = () => {
  const getDuration = useCallback(async () => {
    const imported = await getGifDurationInSeconds(gif); // 127.452
    const publicFile = await getGifDurationInSeconds(staticFile('giphy.gif')); // 2.10
    const remote = await getGifDurationInSeconds('https://media.giphy.com/media/xT0GqH01ZyKwd3aT3G/giphy.gif'); // 3.23
  }, []);

  useEffect(() => {
    getDuration();
  }, []);

  return null;
};
```

## See also

- [`<Gif>`](/docs/gif/gif)
- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/gif/src/get-gif-duration-in-seconds.ts)
